var express = require('express');
var router = express.Router();
let jwtUtils = require('../utils/jwtUtils');
const mail = require('../utils/mailUtil');

const userMid = require('../middleware/user_mid.js');

/**
 * 发送邮件
 */
router.post('/setEM', function (req, resp, next) {
  let { email, subject, text, html } = req.body;
  mail.emailTo(email, subject, text, html, function (v) {
    resp.send(v);
  });
});

/**
 * 根据用户名获取用户数据
 */
router.post('/getEM', function (req, resp, next) {
    userMid.getUserDataByName(req.body.name, resp)
    // resp.send({data:[{Emil:"1044580210@qq.com",id:"1701130086"}]});

});


router.post('/changepwd', function (req, resp, next) {
    userMid.changeUserPwd(req, resp)
});
router.post('/setUser', function (req, resp, next) {
    userMid.insertUser(req, resp)
});
router.post('/insertTodo', function (req, resp, next) {
    userMid.insertTodo(req, resp)
});
module.exports = router;
